#ifndef F100CCSSDEFI0V1_HH
#define F100CCSSDEFI0V1_HH

#include <cstdlib>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <sstream>
#include <iostream>
#include <iomanip> // std::setw
#include <mutex>
#include <array>
#include <tuple>
#include <bitset>
#include <random>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
#include <numeric>
#include <utility> // std::forward
#include <algorithm>
#include <functional>
#include <any>
#include <variant>
#include <optional>
#include <stdexcept>
#include <memory> // std::unique_ptr
#include <chrono>
#include <filesystem>

/* --------------------------------------------- */

template <typename, typename = void> struct cc_has_subscript_t : std::false_type {};
template <typename T> struct cc_has_subscript_t<T, std::void_t<decltype(std::declval<T>()[0])>> : std::true_type {};
template <typename T> inline constexpr bool cc_has_subscript = cc_has_subscript_t<T>::value;

template <typename, typename = void> struct cc_has_resize_t : std::false_type {};
template <typename T> struct cc_has_resize_t<T, std::void_t<decltype(std::declval<T>().resize(std::declval<uint64_t>()))>> : std::true_type {};
template <typename T> inline constexpr bool cc_has_resize = cc_has_resize_t<T>::value;

template <typename, typename U, typename = void> struct cc_has_insert_t : std::false_type {};
template <typename T, typename U> struct cc_has_insert_t<T, U, std::void_t<decltype(std::declval<T>().insert(std::declval<U>()))>> : std::true_type {};
template <typename T, typename U> inline constexpr bool cc_has_insert = cc_has_insert_t<T, U>::value;

template <typename, typename U, typename = void> struct cc_has_pushback_t : std::false_type {};
template <typename T, typename U> struct cc_has_pushback_t<T, U, std::void_t<decltype(std::declval<T>().push_back(std::declval<U>()))>> : std::true_type {};
template <typename T, typename U> inline constexpr bool cc_has_pushback = cc_has_pushback_t<T, U>::value;

template <typename, typename = void> struct cc_has_reserve_t : std::false_type {};
template <typename T> struct cc_has_reserve_t<T, std::void_t<decltype(std::declval<T>().reserve(std::declval<uint64_t>()))>> : std::true_type {};
template <typename T> inline constexpr bool cc_has_reserve = cc_has_reserve_t<T>::value;

template <typename T, typename = void> struct cc_has_size_t : std::false_type {};
template <typename T> struct cc_has_size_t
  < T
  , std::void_t<std::enable_if_t<std::is_same_v<decltype(std::declval<const T&>().size_()), size_t>>>
  > : std::true_type {}; // () const -> size_t
template <typename T> inline constexpr bool cc_has_size = cc_has_size_t<T>::value;

template <typename T, typename = void> struct cc_has_serialize_t : std::false_type {};
template <typename T> struct cc_has_serialize_t
  < T
  , std::void_t<std::enable_if_t<std::is_same_v<decltype(std::declval<const T&>().serialize_(std::declval<void*>())), size_t>>>
  > : std::true_type {}; // (void*) const -> size_t [Big-endian]
template <typename T> inline constexpr bool cc_has_serialize = cc_has_serialize_t<T>::value;

template <typename T, typename = void> struct cc_has_deserialize_t : std::false_type {};
template <typename T> struct cc_has_deserialize_t
  < T
  , std::void_t<std::enable_if_t<std::is_same_v<decltype(std::declval<T&>().deserialize_(std::declval<const void*>())), size_t>>>
  > : std::true_type {}; // (const void*) -> size_t [Big-endian]
template <typename T> inline constexpr bool cc_has_deserialize = cc_has_deserialize_t<T>::value;

template <typename T, typename = void>
class cc_has_stream : public std::false_type {};
template <typename T>
class cc_has_stream<T, std::void_t<decltype(std::declval<std::ostream&>() << std::declval<T>())>> : public std::true_type {};

template <typename T> struct cc_is_string_t : std::is_same<T, std::string> {};
template <typename T> inline constexpr bool cc_is_string = cc_is_string_t<T>::value;

template <typename T> struct cc_is_pair_t : std::false_type {};
template <typename T1, typename T2> struct cc_is_pair_t<std::pair<T1, T2>> : std::true_type {};
template <typename T> inline constexpr bool cc_is_pair = cc_is_pair_t<T>::value;

template <typename T> struct cc_is_tuple_t : std::false_type {};
template <typename... Ts> struct cc_is_tuple_t<std::tuple<Ts...>> : std::true_type {};
template <typename T> inline constexpr bool cc_is_tuple = cc_is_tuple_t<T>::value;

template <typename T> struct cc_is_optional_t : std::false_type {};
template <typename V> struct cc_is_optional_t<std::optional<V>> : std::true_type {};
template <typename T> inline constexpr bool cc_is_optional = cc_is_optional_t<T>::value;

template <typename T> struct cc_is_variant_t : std::false_type {};
template <typename... Vs> struct cc_is_variant_t<std::variant<Vs...>> : std::true_type {};
template <typename T> inline constexpr bool cc_is_variant = cc_is_variant_t<T>::value;

template <typename T> struct cc_is_unique_ptr_t : std::false_type {};
template <typename V, typename D> struct cc_is_unique_ptr_t<std::unique_ptr<V, D>> : std::true_type {};
template <typename T> inline constexpr bool cc_is_unique_ptr = cc_is_unique_ptr_t<T>::value;

template <typename T> struct cc_is_shared_ptr_t : std::false_type {};
template <typename V> struct cc_is_shared_ptr_t<std::shared_ptr<V>> : std::true_type {};
template <typename T> inline constexpr bool cc_is_shared_ptr = cc_is_shared_ptr_t<T>::value;

template <typename T> struct cc_is_duration_t : std::false_type {};
template <typename Rep, typename Period> struct cc_is_duration_t<std::chrono::duration<Rep, Period>> : std::true_type {};
template <typename T> inline constexpr bool cc_is_duration = cc_is_duration_t<T>::value;

template <typename T> struct cc_is_filepath_t : std::is_same<T, std::filesystem::path> {};
template <typename T> inline constexpr bool cc_is_filepath = cc_is_filepath_t<T>::value;

template <typename T> struct cc_is_forward_list_t : std::false_type {};
template <typename V, typename A> struct cc_is_forward_list_t<std::forward_list<V, A>> : std::true_type {};
template <typename T> inline constexpr bool cc_is_forward_list = cc_is_forward_list_t<T>::value;

template <typename T, typename _ = void> struct cc_is_container_t : std::false_type {};
template <typename T> struct cc_is_container_t
  < T
  , std::void_t
    < std::enable_if_t<!std::is_array_v<T>>
    , std::enable_if_t<!cc_is_string<std::decay_t<T>>>
    , std::enable_if_t<!cc_is_forward_list<std::decay_t<T>>>
    , typename T::value_type
    , typename T::iterator
    , decltype(std::declval<T&>().clear())
    , decltype(std::declval<T&>().begin())
    , decltype(std::declval<T&>().end())
    , decltype(std::declval<const T&>().size())
    >
  > : std::true_type {};
template <typename T> inline constexpr bool cc_is_container = cc_is_container_t<T>::value;

template <typename T> size_t cc_size_(const T& obj)
{
  using DecayedT = std::decay_t<T>;
  // 1. Check for member size_()
  if constexpr (cc_has_size<DecayedT>) return obj.size_();
  // 2. std::string (Size prefix + data + null)
  else if constexpr (cc_is_string<DecayedT>)
  {
    return 8 + obj.size() + 1;
  }
  // 3. std::pair (Sum of element sizes)
  else if constexpr (cc_is_pair<DecayedT>)
  {
    return cc_size_(obj.first) + cc_size_(obj.second);
  }
  // 4. std::tuple (Sum of element sizes)
  else if constexpr (cc_is_tuple<DecayedT>)
  {
    size_t total_size = 0;
    std::apply([&](const auto&... args) { ((total_size += cc_size_(args)), ...); }, obj);
    return total_size;
  }
  // 5. Containers (Size prefix + sum of element sizes)
  else if constexpr (cc_is_container<DecayedT>)
  {
    size_t total_size = 8; // element count
    for (const auto& element : obj) total_size += cc_size_(element);
    return total_size;
  }
  // 6. C-Style Array
  else if constexpr (std::is_array_v<T>) // is fixed size
  {
    size_t total_size = 0;
    for (const auto& element : obj) total_size += cc_size_(element);
    return total_size;
  }
  // 7. std::forward_list (size prefix + sum of element sizes)
  else if constexpr (cc_is_forward_list<DecayedT>)
  {
    size_t total_size = 8; // element count
    for (const auto& element : obj) total_size += cc_size_(element);
    return total_size;
  }
  // 8. std::optional (flag + value size if present)
  else if constexpr (cc_is_optional<DecayedT>)
  {
    size_t total_size = 1; // has_value flag
    if (obj.has_value()) total_size += cc_size_(obj.value());
    return total_size;
  }
  // 9. std::variant (index + active value size)
  else if constexpr (cc_is_variant<DecayedT>)
  {
    size_t total_size = 8; // index
    total_size += std::visit([](const auto& value) { return cc_size_(value); }, obj);
    return total_size;
  }
  // 10. std::unique_ptr (flag + pointee size if non-null)
  else if constexpr (cc_is_unique_ptr<DecayedT>)
  {
    size_t total_size = 1; // null flag
    if (obj) total_size += cc_size_(*obj);
    return total_size;
  }
  // 11. std::shared_ptr (flag + pointee size if non-null)
  else if constexpr (cc_is_shared_ptr<DecayedT>)
  {
    size_t total_size = 1; // null flag
    if (obj) total_size += cc_size_(*obj);
    return total_size;
  }
  // 12. std::chrono::duration (count as int64_t)
  else if constexpr (cc_is_duration<DecayedT>)
  {
    return 8; // count
  }
  // 13. std::filesystem::path (serialized as string)
  else if constexpr (cc_is_filepath<DecayedT>)
  {
    std::string str = obj.string();
    return 8 + str.size() + 1;
  }
  // 14. bool
  else if constexpr (std::is_same_v<DecayedT, bool>)
  {
    return 1;
  }
  // 15. Fundamental types and others
  else return sizeof(obj);
}
template <typename T> size_t cc_serialize_(const T& obj, void* buffer)
{
  using DecayedT = std::decay_t<T>;
  uint8_t* ptr = static_cast<uint8_t*>(buffer);
  size_t offset = 0;
  // 1. Check for member serialize_()
  if constexpr (cc_has_serialize<DecayedT>) return obj.serialize_(ptr);
  // 2. std::string (Size prefix + data + null)
  else if constexpr (cc_is_string<DecayedT>)
  {
    uint64_t str_size = obj.size();
    for (int i = 0; i < 8; ++i)
      ptr[i] = (str_size >> (56 - i * 8)) & 0xFF;
    offset += 8;
    memcpy(ptr + offset, obj.c_str(), str_size);
    offset += str_size;
    ptr[offset] = '\0'; // null terminator
    offset += 1;
    return offset;
  }
  // 3. std::pair
  else if constexpr (cc_is_pair<DecayedT>)
  {
    offset += cc_serialize_(obj.first, ptr + offset);
    offset += cc_serialize_(obj.second, ptr + offset);
    return offset;
  }
  // 4. std::tuple
  else if constexpr (cc_is_tuple<DecayedT>)
  {
    std::apply([&](const auto&... args) { ((offset += cc_serialize_(args, ptr + offset)), ...); }, obj);
    return offset;
  }
  // 5. Containers (Size prefix + elements)
  else if constexpr (cc_is_container<DecayedT>)
  {
    uint64_t count = obj.size();
    for (int i = 0; i < 8; ++i)
      ptr[i] = (count >> (56 - i * 8)) & 0xFF;
    offset += 8;
    for (const auto& element : obj) { offset += cc_serialize_(element, ptr + offset); }
    return offset;
  }
  // 6. C-Style Array
  else if constexpr (std::is_array_v<T>) // is fixed size
  {
    for (const auto& element : obj)
    {
      offset += cc_serialize_(element, ptr + offset);
    }
    return offset;
  }
  // 7. std::forward_list (size prefix + elements)
  else if constexpr (cc_is_forward_list<DecayedT>)
  {
    uint64_t count = std::distance(obj.begin(), obj.end());
    for (int i = 0; i < 8; ++i)
      ptr[i] = (count >> (56 - i * 8)) & 0xFF;
    offset += 8;
    for (const auto& element : obj) offset += cc_serialize_(element, ptr + offset);
    return offset;
  }
  // 8. std::optional (flag + value if present)
  else if constexpr (cc_is_optional<DecayedT>)
  {
    ptr[0] = obj.has_value() ? 1 : 0;
    offset += 1;
    if (obj.has_value()) offset += cc_serialize_(obj.value(), ptr + offset);
    return offset;
  }
  // 9. std::variant (index + active value)
  else if constexpr (cc_is_variant<DecayedT>)
  {
    uint64_t index = obj.index();
    for (int i = 0; i < 8; ++i)
      ptr[i] = (index >> (56 - i * 8)) & 0xFF;
    offset += 8;
    offset += std::visit([&](const auto& value) { return cc_serialize_(value, ptr + offset); }, obj);
    return offset;
  }
  // 10. std::unique_ptr (flag + pointee if non-null)
  else if constexpr (cc_is_unique_ptr<DecayedT>)
  {
    ptr[0] = obj ? 1 : 0;
    offset += 1;
    if (obj) offset += cc_serialize_(*obj, ptr + offset);
    return offset;
  }
  // 11. std::shared_ptr (flag + pointee if non-null)
  else if constexpr (cc_is_shared_ptr<DecayedT>)
  {
    ptr[0] = obj ? 1 : 0;
    offset += 1;
    if (obj) offset += cc_serialize_(*obj, ptr + offset);
    return offset;
  }
  // 12. std::chrono::duration (count as int64_t)
  else if constexpr (cc_is_duration<DecayedT>)
  {
    int64_t count = obj.count();
    for (int i = 0; i < 8; ++i)
      ptr[i] = (count >> (56 - i * 8)) & 0xFF;
    return 8;
  }
  // 13. std::filesystem::path (serialized as string)
  else if constexpr (cc_is_filepath<DecayedT>)
  {
    std::string str = obj.string();
    uint64_t str_size = str.size();
    for (int i = 0; i < 8; ++i)
      ptr[i] = (str_size >> (56 - i * 8)) & 0xFF;
    offset += 8;
    memcpy(ptr + offset, str.c_str(), str_size);
    offset += str_size;
    ptr[offset] = '\0';
    offset += 1;
    return offset;
  }
  // 14. bool
  else if constexpr (std::is_same_v<DecayedT, bool>)
  {
    ptr[0] = obj ? 1 : 0;
    return 1;
  }
  // 15. Fundamental types and others
  else
  {
    if constexpr (std::is_same_v<DecayedT, uint16_t> || std::is_same_v<DecayedT, int16_t>)
    { // uint16, int16
      for (int i = 0; i < 2; ++i)
        ptr[i] = (obj >> (8 - i * 8)) & 0xFF;
      return 2;
    }
    else if constexpr (std::is_same_v<DecayedT, uint32_t> || std::is_same_v<DecayedT, int32_t>)
    { // uint32, int32
      for (int i = 0; i < 4; ++i)
        ptr[i] = (obj >> (24 - i * 8)) & 0xFF;
      return 4;
    }
    else if constexpr (std::is_same_v<DecayedT, uint64_t> || std::is_same_v<DecayedT, int64_t>)
    { // uint64, int64
      for (int i = 0; i < 8; ++i)
        ptr[i] = (obj >> (56 - i * 8)) & 0xFF;
      return 8;
    }
    else if constexpr (std::is_same_v<DecayedT, float>)
    {
      uint32_t obj_int;
      memcpy(&obj_int, &obj, 4);
      for (int i = 0; i < 4; ++i)
        ptr[i] = (obj_int >> (24 - i * 8)) & 0xFF;
      return 4;
    }
    else if constexpr (std::is_same_v<DecayedT, double>)
    {
      uint64_t obj_long;
      memcpy(&obj_long, &obj, 8);
      for (int i = 0; i < 8; ++i)
        ptr[i] = (obj_long >> (56 - i * 8)) & 0xFF;
      return 8;
    }
    else
    { // char, bool, void*, etc.
      memcpy(ptr, &obj, sizeof(obj));
      return sizeof(obj);
    }
  }
}
template <typename T>
size_t cc_deserialize_(T& obj, const void* buffer)
{
  using DecayedT = std::decay_t<T>;
  const uint8_t* ptr = static_cast<const uint8_t*>(buffer);
  size_t offset = 0;
  // 1. Check for member deserialize_()
  if constexpr (cc_has_deserialize<DecayedT>) return obj.deserialize_(ptr);
  // 2. std::string (Read size prefix, read data)
  else if constexpr (cc_is_string<DecayedT>)
  {
    uint64_t str_size = 0;
    for (int i = 0; i < 8; ++i)
      str_size |= static_cast<uint64_t>(static_cast<uint8_t>(ptr[i])) << (56 - i * 8);
    offset += 8;
    obj = std::string(static_cast<const char*>(buffer) + offset, str_size);
    offset += (str_size + 1);
    return offset;
  }
  // 3. std::pair
  else if constexpr (cc_is_pair<DecayedT>)
  {
    offset += cc_deserialize_(obj.first, ptr + offset);
    offset += cc_deserialize_(obj.second, ptr + offset);
    return offset;
  }
  // 4. std::tuple
  else if constexpr (cc_is_tuple<DecayedT>)
  {
    std::apply([&](auto&... args) { ((offset += cc_deserialize_(args, ptr + offset)), ...); }, obj);
    return offset;
  }
  // 5. Containers (Read size prefix, resize/clear, deserialize elements)
  else if constexpr (cc_is_container<DecayedT>)
  {
    uint64_t count = 0;
    for (int i = 0; i < 8; ++i)
      count |= static_cast<uint64_t>(static_cast<uint8_t>(ptr[i])) << (56 - i * 8);
    offset += 8;
    using ElementType = typename DecayedT::value_type;
    obj.clear();
    if constexpr (std::is_same_v<DecayedT, std::vector<bool>>)
    { // C++ vector<bool>
      obj.resize(count);
      for (uint64_t i = 0; i < count; ++i)
      {
        bool temp = false;
        offset += cc_deserialize_(temp, ptr + offset);
        obj[i] = temp; // assign to std::_Bit_reference
      }
    }
    else if constexpr (cc_has_resize<DecayedT> && cc_has_subscript<DecayedT>)
    { // vector-like with resize
      obj.resize(count);
      for (uint64_t i = 0; i < count; ++i)
      {
        offset += cc_deserialize_(obj[i], ptr + offset);
      }
    }
    else if constexpr (cc_has_insert<DecayedT, ElementType>)
    { // set/map-like
      for (uint64_t i = 0; i < count; ++i)
      {
        if constexpr (cc_is_pair<ElementType>)
        { // map-like with const key
          using KeyType = std::remove_const_t<typename ElementType::first_type>;
          using ValueType = typename ElementType::second_type;
          KeyType key;
          ValueType value;
          offset += cc_deserialize_(key, ptr + offset);
          offset += cc_deserialize_(value, ptr + offset);
          obj.emplace(std::move(key), std::move(value));
        }
        else
        { // set-like
          ElementType element;
          offset += cc_deserialize_(element, ptr + offset);
          obj.insert(std::move(element));
        }
      }
    }
    else if constexpr (cc_has_pushback<DecayedT, ElementType>)
    { // vector-like with push_back
      if constexpr (cc_has_reserve<DecayedT>) { obj.reserve(count); }
      for (uint64_t i = 0; i < count; ++i)
      {
        ElementType element;
        offset += cc_deserialize_(element, ptr + offset);
        obj.push_back(std::move(element));
      }
    }
    else static_assert(sizeof(DecayedT) == 0, "cc_deserialize_(): Container deserialization needs resize/insert/push_back.");
    return offset;
  }
  // 6. C-Style Array
  else if constexpr (std::is_array_v<T>) // is fixed size
  {
    for (auto& element : obj)
    {
      offset += cc_deserialize_(element, ptr + offset);
    }
    return offset;
  }
  // 7. std::forward_list
  else if constexpr (cc_is_forward_list<DecayedT>)
  {
    uint64_t count = 0;
    for (int i = 0; i < 8; ++i)
      count |= static_cast<uint64_t>(static_cast<uint8_t>(ptr[i])) << (56 - i * 8);
    offset += 8;
    using ElementType = typename DecayedT::value_type;
    obj.clear();
    std::vector<ElementType> temp;
    temp.reserve(count);
    for (uint64_t i = 0; i < count; ++i)
    {
      ElementType element;
      offset += cc_deserialize_(element, ptr + offset);
      temp.push_back(std::move(element));
    }
    obj.assign(temp.begin(), temp.end());
    return offset;
  }
  // 8. std::optional
  else if constexpr (cc_is_optional<DecayedT>)
  {
    bool has_value = ptr[0] != 0;
    offset += 1;
    if (has_value)
    {
      typename DecayedT::value_type value;
      offset += cc_deserialize_(value, ptr + offset);
      obj = std::move(value);
    }
    else obj = std::nullopt;
    return offset;
  }
  // 9. std::variant
  else if constexpr (cc_is_variant<DecayedT>)
  {
    uint64_t index = 0;
    for (int i = 0; i < 8; ++i)
      index |= static_cast<uint64_t>(static_cast<uint8_t>(ptr[i])) << (56 - i * 8);
    offset += 8;
    bool deserialized = false;
    [&]<size_t... Is>(std::index_sequence<Is...>)
    {
      (
        (Is == index
          ? (offset += cc_deserialize_(obj.template emplace<Is>(), ptr + offset), deserialized = true)
          : false
        )
      || ...);
    } (std::make_index_sequence<std::variant_size_v<DecayedT>>{});
    if (!deserialized)
    {
      if (index >= std::variant_size_v<DecayedT>) throw std::runtime_error("cc_deserialize_(): Invalid variant index read from buffer.");
      else throw std::runtime_error("cc_deserialize_(): Failed to dispatch variant deserialization.");
    }
    return offset;
  }
  // 10. std::unique_ptr
  else if constexpr (cc_is_unique_ptr<DecayedT>)
  {
    bool is_non_null = ptr[0] != 0;
    offset += 1;
    if (is_non_null)
    {
      using PointeeType = typename DecayedT::element_type;
      auto unique_ptr = std::make_unique<PointeeType>();
      offset += cc_deserialize_(*unique_ptr, ptr + offset);
      obj = std::move(unique_ptr);
    }
    else obj.reset();
    return offset;
  }
  // 11. std::shared_ptr
  else if constexpr (cc_is_shared_ptr<DecayedT>)
  {
    bool is_non_null = ptr[0] != 0;
    offset += 1;
    if (is_non_null)
    {
      using PointeeType = typename DecayedT::element_type;
      auto shared_ptr = std::make_shared<PointeeType>();
      offset += cc_deserialize_(*shared_ptr, ptr + offset);
      obj = std::move(shared_ptr);
    }
    else obj.reset();
    return offset;
  }
  // 12. std::chrono::duration
  else if constexpr (cc_is_duration<DecayedT>)
  {
    int64_t count = 0;
    for (int i = 0; i < 8; ++i)
      count |= static_cast<uint64_t>(static_cast<uint8_t>(ptr[i])) << (56 - i * 8);
    obj = DecayedT{count};
    return 8;
  }
  // 13. std::filesystem::path
  else if constexpr (cc_is_filepath<DecayedT>)
  {
    uint64_t str_size = 0;
    for (int i = 0; i < 8; ++i)
      str_size |= static_cast<uint64_t>(static_cast<uint8_t>(ptr[i])) << (56 - i * 8);
    offset += 8;
    std::string str(static_cast<const char*>(buffer) + offset, str_size);
    obj = std::filesystem::path(str);
    offset += (str_size + 1);
    return offset;
  }
  // 14. bool
  else if constexpr (std::is_same_v<DecayedT, bool>)
  {
    obj = ptr[0] != 0;
    return 1;
  }
  // 15. Fundamental types and others
  else
  {
    if constexpr (std::is_same_v<DecayedT, uint16_t> || std::is_same_v<DecayedT, int16_t>)
    {
      obj = 0;
      for (int i = 0; i < 2; ++i)
        obj |= static_cast<uint16_t>(static_cast<uint8_t>(ptr[i])) << (8 - i * 8);
      return 2;
    }
    else if constexpr (std::is_same_v<DecayedT, uint32_t> || std::is_same_v<DecayedT, int32_t>)
    {
      obj = 0;
      for (int i = 0; i < 4; ++i)
        obj |= static_cast<uint32_t>(static_cast<uint8_t>(ptr[i])) << (24 - i * 8);
      return 4;
    }
    else if constexpr (std::is_same_v<DecayedT, uint64_t> || std::is_same_v<DecayedT, int64_t>)
    {
      obj = 0;
      for (int i = 0; i < 8; ++i)
        obj |= static_cast<uint64_t>(static_cast<uint8_t>(ptr[i])) << (56 - i * 8);
      return 8;
    }
    else if constexpr (std::is_same_v<DecayedT, float>)
    {
      uint32_t obj_int = 0;
      for (int i = 0; i < 4; ++i)
        obj_int |= static_cast<uint32_t>(static_cast<uint8_t>(ptr[i])) << (24 - i * 8);
      memcpy(&obj, &obj_int, 4);
      return 4;
    }
    else if constexpr (std::is_same_v<DecayedT, double>)
    {
      uint64_t obj_long = 0;
      for (int i = 0; i < 8; ++i)
        obj_long |= static_cast<uint64_t>(static_cast<uint8_t>(ptr[i])) << (56 - i * 8);
      memcpy(&obj, &obj_long, 8);
      return 8;
    }
    else
    {
      memcpy(&obj, ptr, sizeof(obj));
      return sizeof(obj);
    }
  }
}

#endif
